﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OnlineStore.Dal;

namespace OnlineStore.Bll
{
    public class bizProduct
    {
        public static int Stock(tbProduct tb)
        {
            return Convert.ToInt32(tb.Stock_Qty)+Convert.ToInt32(tb.Pur_Qty)-  Convert.ToInt32(tb.Ord_Qty);
        }
        DalProduct _DalProduct;
        public bizProduct()
        {
            _DalProduct = new DalProduct();
        }
        public List<tbProduct> Search(string keyword)
        {
            return _DalProduct.Search(keyword, "-1", "1", "1", 0);
        }
        public List<tbProduct> Search(string Type,string page)
        {
            int Page = page==null? 1:int.Parse(page);
            if (Page > 1) Page -= 1;
            else Page = 0;
            return _DalProduct.Search(Type, Page);
        }
        public List<tbProduct> Search(string keyword, string type, string Introduce, string Detail, string page)
        {
            int _Page = page == null ? 1 : int.Parse(page);
            if (_Page > 1) _Page -= 1;
            else _Page = 0;
            return _DalProduct.Search(keyword, type, Introduce, Detail, _Page);
        }
        public tbProduct SearchPorduct(string ID)
        {
            if (ID == null) return null;
            return _DalProduct.Search(int.Parse(ID));
        }
        public int NumberItems
        {
            get { return _DalProduct.NumberItems; }
        }
        //private int _id, _pur_Qty, _Ord_Qty, _Stock_Qty, _Clock;
        //private string _name, _product_id, _size, _color, _father, _Introduce, _Detail, _Picture, _Type;
        //private float _price;
        //public string Name
        //{
        //    get{return _name;}
        //    set{_name=value;}
        //}
        //public string Product_id
        //{
        //    get { return _product_id; }
        //    set { _product_id = value; }
        //}
        //public string Size
        //{
        //    get { return _size; }
        //    set { _size = value; }
        //}
        //public string Color
        //{
        //    get { return _color; }
        //    set { _color = value; }
        //}
        //public string Father
        //{
        //    get { return _father; }
        //    set { _father = value; }
        //}
        //public string Introduce
        //{
        //    get { return _Introduce; }
        //    set { _Introduce = value; }
        //}
        //public string Detail
        //{
        //    get { return _Detail; }
        //    set { _Detail = value; }
        //}
        //public string Picture
        //{
        //    get { return _Picture; }
        //    set { _Picture = value; }
        //}
        //public string Type
        //{
        //    get { return _Type; }
        //    set { _Type = value; }
        //}
        //public int ID
        //{
        //    get{return _id; }
        //    set{_id = value;}
        //}
        //public int Pur_Qty
        //{
        //    get{return _pur_Qty; }
        //    set{_pur_Qty = value;}
        //}
        //public int Ord_Qty
        //{
        //    get{return _Ord_Qty; }
        //    set{_Ord_Qty = value;}
        //}
        //public int Stock_Qty
        //{
        //    get{return _Stock_Qty; }
        //    set{_Stock_Qty = value;}
        //}
        //public int Clock
        //{
        //    get{return _Clock; }
        //    set{_Clock = value;}
        //}
        //public float Price
        //{
        //    get{return _price; }
        //    set{_price = value;}
        //}
    }
}